package com.wx.config;

import com.wx.entity.WxProperties;
import com.wx.service.WxService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(WxProperties.class)
@ConditionalOnWebApplication
public class WxServiceAutoConfiguration {

    private Logger logger = LoggerFactory.getLogger(WxServiceAutoConfiguration.class);

    @Autowired
    private WxProperties wxProperties;


    public WxServiceAutoConfiguration(){
        logger.info("wx-autoconfiguration success...");
    }

    /**
     * 创建wxService
     * @return
     */
    @Bean
    public WxService wxService(){
        WxService wxService = new WxService(wxProperties);
        return wxService;
    }

}
